package cn.school.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import cn.school.service.Service;
import cn.school.util.StringKit;

/**
 * Servlet implementation class StudentDeleteAjaxServlet
 */
@WebServlet("/StudentDeleteAjaxServlet")
public class StudentDeleteAjaxServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public StudentDeleteAjaxServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	Service service = new Service();

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		// response.getWriter().append("Served at: ").append(request.getContextPath());
		response.setContentType("application/json;charset=utf-8");
		long stuno = StringKit.toLong(request.getParameter("stuno"));
		int p = service.deleteByStuId(stuno);
		String result = JSON.toJSONString(p);
		response.getWriter().print(result);

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
